﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace CSE445HW5.UserProtected
{
    public partial class Weather : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void getWeather_Click(object sender, EventArgs e)
        {
            string zipCode = textBoxZipCode.Text;

            if (zipCode != "")
            {
                weatherOutput.Text = getWeatherInformation(zipCode);
            }
        }

        public string getWeatherInformation(string zipCode)
        {
            com.cdyne.wsf.Weather weather = new com.cdyne.wsf.Weather();
            com.cdyne.wsf.WeatherReturn weatherByZip = weather.GetCityWeatherByZIP(zipCode);

            string city = weatherByZip.City;
            string state = weatherByZip.State;
            string temperature = weatherByZip.Temperature;
            string wind = weatherByZip.Wind;

            string output = city + ", " + state + ". " + "Temperature is " + temperature + " degrees. " + "Wind is " + wind + " mph.";

            return output;
        }
    }
}